﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace InsightAuto.Web.Controllers
{
    public class UploadController : Controller
    {
        [HttpPost]
        public JsonResult Upload()
        {
            string path = Path.Combine(this.Server.MapPath("~/Images/News"), "temp.jpg");
            var file = this.Request.BinaryRead(this.Request.TotalBytes);
            System.IO.File.WriteAllBytes(path, file);

            var result = new { err = "", msg = UrlHelper.GenerateContentUrl("~/Images/News/temp.jpg", this.HttpContext) };
            
            return Json(result);
        }
    }
}
